/**
 * Created by AranciaCheng on 2017/8/20.
 */
var express = require('express')
var app = express()

app.use(express.static('static'))
app.use(express.static('dist'))

var appData = require('./data.json')
var seller = appData.seller
var goods = appData.goods
var ratings = appData.ratings

// var apiRoutes = express.Router()

app.get('/', function (req, res) {
  res.sendFile(__dirname + '/' + 'index.html')
})

app.get('/api/seller', function (req, res) {
  res.json({
    error: 0,
    data: seller
  })
})

app.get('/api/goods', function (req, res) {
  res.json({
    error: 0,
    data: goods
  })
})

app.get('/api/ratings', function (req, res) {
  res.json({
    error: 0,
    data: ratings
  })
})

app.listen(8081, function () {
  console.log('serve at localhost')
})
